﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using BlueCMS.Core.Data.Query.Clauses;

namespace BlueCMS.Core.Data.Query.Columns
{
    public class UpdateColumn : Column, IUpdateColumn
    {
        public UpdateType Type { get; set; }
        public object Value { get; set; }
        SetClause Clause { get; set; }

        public UpdateColumn(string name, SetClause clause)
            : base(name)
        {
            Clause = clause;
        }

        ISetClause IUpdateColumn.Aggregate(string clause)
        {
            Type = UpdateType.Aggregate;
            Value = clause;
            return Clause;
        }

        ISetClause IUpdateColumn.Column(string name)
        {
            Type = UpdateType.Column;
            Value = name;
            return Clause;
        }

        ISetClause IUpdateColumn.Constant(object value)
        {
            Type = UpdateType.Constant;
            Value = value;
            return Clause;
        }

        ISetClause IUpdateColumn.Parameter(object value)
        {
            Type = UpdateType.Parameter;
            Value = value;
            return Clause;
        }

        ISetClause IUpdateColumn.SubSelect(Action<SelectQuery> subquery)
        {
            Type = UpdateType.SubSelect;
            Value = subquery;
            return Clause;
        }
    }
}
